(window as any).fetch = (url: string, init: {}) => {
    return Promise.resolve({
        url: url,
        ok: true,
        json: () => { },
        status: 200,
        statusText: 'OK',
        type: 'basic',
        headers: {
            get: (hname: string) => {
                switch (hname.toLowerCase()) {
                    case 'content-type':
                        return 'application/json';
                    default:
                        return '';
                }
            }
        }
    });
};

const setWindowEnv = (base: string) =>
    (window as any).env = {
        base: base,
        api: base + '/api',
    };

export { setWindowEnv };